import java.util.Scanner;

public class HuoXingWen {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        HuoXingWen huoXingWen = new HuoXingWen();
        huoXingWen.xx(scanner.nextLine());
        scanner.close();
    }

    public void xx(String origin) {
        String[] split = origin.split("\\$");
        long[] container = new long[split.length];
        for (int i = 0; i < split.length; i++) {
            // 这是带#号的字符串
            String s = split[i];
            String[] split1 = s.split("\\#");
            long tmp = 0;
            for (int i1 = 0; i1 < split1.length; i1++) {
                if (tmp == 0) {
                    tmp = Long.parseLong(split1[i1]);
                } else {
                    tmp = jinhao(tmp, Long.parseLong(split1[i1]));
                }
            }
            container[i] = tmp;
        }

        long tmp = 0;
        for (int i = 0; i < container.length; i++) {
            if (tmp == 0) {
                tmp = container[i];
            } else {
                tmp = meiyuan(tmp, container[i]);
            }
        }
        System.out.print(tmp);
    }

    private long jinhao(long x, long y) {
        return 4 * x + 3 * y + 2;
    }

    private long meiyuan(long x, long y) {
        return 2 * x + y + 3;
    }
}
